package com.medata.service.impl;

import com.medata.dataObject.Tasks;
import com.medata.repository.TasksRepository;
import com.medata.service.TasksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：zb
 * @date ：Created in 2019/11/5 0005 14:16
 * @description：
 */
@Service
public class TasksServiceImpl implements TasksService {
    @Autowired
    private TasksRepository repository;
    @Override
    public List<Tasks> findByUsernameOrderByCreateTime(String username,Integer page,Integer pagesize) {
        Pageable pageable=new PageRequest(page,pagesize);
        List<Tasks> content = repository.findByUsernameOrderByCreateTimeDesc(username, pageable).getContent();
        return content;
    }
    @Override
    public void save(Tasks tasks) {
        repository.save(tasks);
    }

    @Override
    public Tasks findById(Integer id) {
        return repository.findById(id);
    }
}
